package com.geline.uploadfile.pojo;

import com.geline.uploadfile.enums.FileServerEnum;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * 删除文件定时任务配置
 * @author: mengxin
 * @date: 2022/11/14 15:09
 */
@Getter
@Setter
@ConfigurationProperties(prefix = "job-upload-file")
public class JobUploadFileProperties {

    //上传文件保存根目录
    private String bucket = "/root/data/files/";
    //上传文件请求头
    private String fileServerUrl = "http://127.0.0.1/";

    //处理任务：删除垃圾文件
    private List<JobUploadFile> list;

    //根据表名取文件服务器类型
    public FileServerEnum getSysFileServer(String table){
        JobUploadFile bean = list.stream().filter(row -> row.getTable().equals(table)).findFirst().orElse(null);
        return FileServerEnum.valueOf(bean.getSysFileServer());
    }
}
